package com.wyp168.juc;

/**
 * @ClassName JoinDemo
 * @Description TODO
 * @Author wyp168
 * @Date 2022/7/8 12:10
 */
public class JoinDemo001 {
    public static void main(String[] args) throws InterruptedException {

        //主线程
        final Thread mainThread = Thread.currentThread();

        Thread threadA = new Thread(() -> {
            //死循环
            for (;;) {}
        });

        Thread threadB = new Thread(() -> {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            mainThread.interrupt();
        });

        threadA.start();
        threadB.start();
        threadA.join();

    }

}
